package cj.web.activity.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.activity.domain.SCGoods;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SCGoodsDAO{
	
	@SQL("SELECT id,type,title,image,descs,status,createAt,createUser,updateAt,updateUser,prize FROM SCGoods WHERE 1=1  #if(:t.type!=null){ AND type=:t.type }  #if(:t.title!=null){ AND title LIKE '%##(:t.title)%' }  #if(:t.status!=null){ AND status=:t.status } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<SCGoods> query(@SQLParam("t") SCGoods sCGoods);
	
	@SQL("SELECT count(1) FROM SCGoods WHERE 1=1  #if(:t.type!=null){ AND type=:t.type }  #if(:t.title!=null){ AND title LIKE '%##(:t.title)%' }  #if(:t.status!=null){ AND status=:t.status } ")
    List<SCGoods> querysize(@SQLParam("t") SCGoods sCGoods);
	
	@SQL("SELECT id,type,title,status,prize FROM SCGoods WHERE 1=1  #if(:t.type!=null){ AND type=:t.type }  #if(:t.title!=''){ AND title LIKE '%##(:t.title)%' }  #if(:t.status!=null){ AND status=:t.status } ORDER BY status ASC,type ASC,updateAt desc LIMIT :t.start,:t.length ")
    List<SCGoods> getList(@SQLParam("t") SCGoods sCGoods);
	
	@SQL("SELECT count(1) FROM SCGoods WHERE 1=1  #if(:t.type!=null){ AND type=:t.type }  #if(:t.title!=''){ AND title LIKE '%##(:t.title)%' }  #if(:t.status!=null){ AND status=:t.status } ")
    int getSize(@SQLParam("t") SCGoods sCGoods);
    
    @SQL("select id,type,title,image,descs,status,createAt,createUser,updateAt,updateUser,prize from SCGoods where id=:1")
    SCGoods queryById(String id);
    
    @SQL("INSERT INTO SCGoods (type,title,image,descs,status,createAt,createUser,updateAt,updateUser,prize) VALUES (:t.type,:t.title,:t.image,:t.descs,:t.status,now(),:t.createUser,now(),:t.updateUser,:t.prize)")
    void create(@SQLParam("t") SCGoods sCGoods);
	
	@SQL("UPDATE SCGoods SET type=:t.type,title=:t.title,image=:t.image,descs=:t.descs,status=:t.status,updateAt=now(),updateUser=:t.updateUser,prize=:t.prize WHERE id=:t.id")
    void update(@SQLParam("t") SCGoods sCGoods);
    
    @SQL("UPDATE SCGoods SET status=:2,updateAt=now() WHERE id=:1")
    void changeStatus(String id, int status);
}